package org.rich.charlesmurphy.core;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Describes the format of data.
 * @author Rich O'Connell
 */
public class Descriptor implements Iterable<String> {

	//ordered list of field names
	private List<String> fieldNames;

	public Descriptor() {
		fieldNames = new ArrayList<String>();
	}

	public Descriptor(List<String> fieldNames) {
		if (fieldNames != null) {
			setFieldNames(fieldNames);
		}
		else {
			fieldNames = new ArrayList<String>();
		}
	}

	/**
	 * @param fieldNames the fieldNames to set
	 */
	public void setFieldNames(List<String> fieldNames) {
		this.fieldNames = fieldNames;
	}

	public String getFieldName(int index) {
		return fieldNames.get(index);
	}

	public String[] getFieldNamesArray() {
		return fieldNames.toArray(new String[fieldNames.size()]);
	}

	public List<String> getFieldNames() {
		return fieldNames;
	}

	public int size() {
		return fieldNames.size();
	}

	public Iterator<String> iterator() {
		return fieldNames.iterator();
	}

}
